﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using GalaSoft.MvvmLight.Command;
using SkiTracker.Model;

namespace SkiTracker.Converter
{
    public class MessageToNavigateCommandConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var message = value as Message;
            if (message == null) return DependencyProperty.UnsetValue;

            return new RelayCommand(() => App.RootFrame.Navigate(new Uri(string.Format(@"/View/ReadMessagePage.xaml?id={0}", message.Id), UriKind.Relative)));
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
